package priv.pfz.basedao.lab.performance;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.function.Function;

/**
 * @author yyjxp
 * 2024/8/4 15:35
 */
public class DirectlyCallLambdaMethod implements ReflectTest {
    private final List<Function<TestBean, ?>> functions = Lists.newArrayList();

    public DirectlyCallLambdaMethod() {
        functions.add(TestBean::getA);
        functions.add(TestBean::getB);
        functions.add(TestBean::getC);
        functions.add(TestBean::getD);
        functions.add(TestBean::getE);
        functions.add(TestBean::getA2);
        functions.add(TestBean::getB2);
        functions.add(TestBean::getC2);
        functions.add(TestBean::getD2);
        functions.add(TestBean::getE2);
    }

    @Override
    public String name() {
        return "直接调用getter的lambda";
    }

    @Override
    public void run(TestBean bean) {
        for (Function<TestBean, ?> function : functions) {
            function.apply(bean);
        }
    }
}
